/**
 * 
 */
package com.demo2do.boyle.backend.service.report.impl;

import java.util.List;

import org.apache.commons.lang3.ClassUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.demo2do.boyle.backend.service.impl.DataServiceImpl;
import com.demo2do.boyle.backend.service.report.StatisticsConvergeService;
import com.demo2do.boyle.common.entity.report.StatisticsConverge;
import com.demo2do.core.persistence.GenericDaoSupport;
import com.demo2do.core.web.resolver.Page;

/**
 * @author Jason.Y
 *
 */
@Service("statisticsConvergeService")
public class StatisticsConvergeServiceImpl extends DataServiceImpl<StatisticsConverge> implements StatisticsConvergeService {

	@Autowired 
	private GenericDaoSupport genericDaoSupport;
	
	/* (non-Javadoc)
     * @see com.demo2do.boyle.backend.service.DataService#listByPage(Class<StatisticsConverge> clazz, Page page, Integer id)
     */
    @SuppressWarnings("unchecked")
	public List<StatisticsConverge> listByPage(Class<StatisticsConverge> clazz, Page page, Integer id) {
    	
    	List<StatisticsConverge> result = genericDaoSupport.searchForList("FROM " + ClassUtils.getShortClassName(clazz) + " where aduserId = " + id, page.getBeginIndex(), page.getMaxResultRecords());
        page.calculate(result.size());
        return result.size() > page.getEveryPage() ? result.subList(0, page.getEveryPage()) : result;
    }

}
